package com.xfcy.blog.controller.common;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xfcy.blog.annotation.OperationLogger;
import com.xfcy.blog.common.R;
import com.xfcy.blog.service.CloudOssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 图片上传
 *
 * @author 晓风残月Lx
 * @date 2023/5/4 11:46
 */
@RestController
@RequestMapping("/file")
@Api(tags = "图片上传-接口")
public class FileUploadController {

    @Resource
    private CloudOssService cloudOssService;

    @OperationLogger(value = "上传图片")
    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    @SaCheckPermission("/file/upload")
    @ApiOperation(value = "上传图片", httpMethod = "POST", response = R.class, notes = "上传图片")
    public R upload(MultipartFile multipartFile) {
        return cloudOssService.upload(multipartFile);
    }

    @OperationLogger(value = "批量删除图片")
    @RequestMapping(value = "/delBatchFile", method = RequestMethod.POST)
    @SaCheckPermission("/file/delBatchFile")
    @ApiOperation(value = "批量删除图片", httpMethod = "POST", response = R.class, notes = "批量删除图片")
    public R deleteBatch(String... key) {
        return cloudOssService.delBatchFile(key);
    }



}
